<?php
/**********************************读取数据*************************************/
//获取当前event下面的companyactivity中identify为newslist的list，循环展示出来
$eventTable = new BAEventSheet();
$event = $eventTable->getListById($eventId);
$activityTable = new BASheet('companyActivity',$event);

//获取companyactivity这个table中identify为newslist的list
$newsActivityView = $activityTable->getView(array('itemData'=>array('identity' => 'newslist')));

//用于存储表中identify为newslist的activity的companycontent
$newsListArr = array();
foreach ($newsActivityView as $newsActivity) {
    $contentTable = new BASheet('companyContent', $newsActivity);
    $contentView = $contentTable->getView();
    $newsListArr = array_merge($newsListArr, $contentView);
}
$newsListArr = array_slice($newsListArr, 0, 5);
$reserve_arr=array_reverse($newsListArr);
/**********************************结束读取数据*********************************/
echo $control->renderView("header_home");
?>
<!-- ******************** HeaderWrap ********************-->
<div id="headerwrap">
    <header class="clearfix">
        <h1><span>涵信集团</span><br/><br/>hamshun.com</h1>
        <div class="container" style="padding-top: 80px;">
            <div class="row">
                <div class="span12">
                    <h2>卓越品质，铸就辉煌产业；非凡创造，谱写世纪华章！<br/>—创新不断，追求永不止！</h2>
                </div>
            </div>
            <div class="row">
                <div class="span12">
                    <ul class="icon">
                        <?php
                        $ajaxScript1 =  $control->getAjaxScript('ShowTrendsList', array(
                            'cooker' => 'BWCompanyInfoCooker@ShowTrendsList',
                            'viewName' => 'news_list'
                        ));
                        ?>
                        <li onclick="<?php echo $ajaxScript1;?>">
                            <a href="#">
                                <i class="pinterest-circled"><img src="<?php echo Yii::app()->request->baseUrl . '/images/BWeEvent2/news.png';?>" width="50" height="50"><br/><font>涵信动态</font></i>
                            </a>
                        </li>
                        <?php
                        $ajaxScript2 =  $control->getAjaxScript('ShowCompanyInfo', array(
                            'cooker' => 'BWCompanyInfoCooker@ShowCompanyInfo',
                            'viewName' => 'about'
                        ));
                        ?>
                        <li onclick="<?php echo $ajaxScript2;?>">
                            <a href="#">
                                <i class="pinterest-circled"><img src="<?php echo Yii::app()->request->baseUrl . '/images/BWeEvent2/man.png';?>" width="50" height="50"><br/><font>关于涵信</font></i>
                            </a>
                        </li>
                        <?php
                        $ajaxScript3 =  $control->getAjaxScript('ShowContactUs', array(
                            'cooker' => 'BWCompanyInfo@ShowContactUs',
                            'viewName' => 'contactus'
                        ));
                        ?>
                        <li onclick="<?php echo $ajaxScript3;?>">
                            <a href="#">
                                <i class="pinterest-circled"><img src="<?php echo Yii::app()->request->baseUrl . '/images/BWeEvent2/phone.png';?>" width="50" height="50"><br/><font>联系我们</font></i>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </header>
</div>
<!--******************** News Section ********************-->
<section id="news" class="single-page scrollblock">
    <div class="container">
        <!-- Three columns -->
        <div class="row">
            <?php
            $i = 0; //用于判断输出row
            foreach ($reserve_arr as $newsList) {
                $newsId = $newsList->getId();
                $newsTime=$newsList->getItem('time')->getValue();
                $newsImage=$newsList->getItem('image')->getValue();
                $newsName = $newsList->getItem('name')->getValue();
                $newsDescription = $newsList->getItem('description')->getValue();
                $newsDescription = mb_substr(str_replace('&nbsp;', '', strip_tags($newsDescription)), 0, 80, 'utf-8');
                //生成ajax链接
                $ajaxScript =  $control->getAjaxScript('ShowArticle', array(
                    'cooker' => 'BWCompanyInfoCooker@ShowArticle',
                        'backCooker' => 'BWCompanyInfo@ShowHome',
                        'newsId' => $newsId,
                        'htmlOptions' => array(
                            'class' => 'more-link'
                )));
                ?>
                <article class="span4 post" onclick="<?php echo $ajaxScript;?>"> <img class="img-news" src="<?php echo Yii::app()->request->baseurl. $newsImage;?>">
                    <div class="inside">
                        <p class="post-date"><i class="icon-calendar"></i><?php echo $newsTime;?></p>
                        <h2><?php echo $newsName;?></h2>
                        <div class="entry-content">
                            <p><?php echo $newsDescription;?> ...</p>
                        </div>
                    </div>
                </article>
            <?php
                $i++;
                if($i%3 == 0) {
                    echo '</div>';
                    echo '<div class="row">';
                }
            }
            ?>
        </div>
        <!-- /.row -->
        <!-- /.container -->
</section>
<?php
echo $control->renderView("footer");
?>